#include <memory>
#include <iostream>
class Base {
public:
    virtual void perform() {
        std::cout << "Base::perform\n";
    }
};
class Derived : public Base {
public:
    void perform() override {
        std::cout << "Derived::perform\n";
    }
};

int main() {
    std::shared_ptr<Base> basePtr = std::make_shared<Derived>(); // 向上转型
    std::shared_ptr<Derived> derivedPtr = std::dynamic_pointer_cast<Derived>(basePtr);

    if (derivedPtr) {
        derivedPtr->perform(); // 正确调用 Derived 的 perform
    } else {
        std::cout << "Conversion failed\n";
    }
    return 0;
}